/*
* isProject 是否是项目大屏 true是
* isBoard是否是大屏 true是
*
* 使用位置：项目大屏-人员实名制-人员地图首页-人员大屏
*
* */
import {
    getAllCompangList,
    getCorpList,
    getEmpBankAdd,
    getEmpBankDel,
    getEmpBankEdit,
    getEmpBankEnable,
    getEmpBankList,
    getEmpCertAdd,
    getEmpCertDel,
    getEmpCertEdit,
    getEmpCertList,
    getEmpCertUploadCertFile,
    getEmpConfessAdd,
    getEmpConfessEdit,
    getEmpConfessList,
    getEmpConfessUserList,
    getEmpContractAdd,
    getEmpContractDel,
    getEmpContractEdit,
    getEmpContractList,
    getEmpGetPayrollList,
    getEmpGetRewardList,
    getEmpHealthReportAdd,
    getEmpHealthReportEdit,
    getEmpHealthReportList,
    getEmpQr,
    getEmpTrainList,
    getFenceList,
    getIndexMapEmpFvs,
    getIndexMapEmpPoly, getIndexMapEmpTab,
    getMapEmpList,
    getPersonnelDetails,
    getStreamUrl,
    getTypeList,
    getEmpConfessDel,
    getEmpHealthReportDel,
} from "@/api/api";
import {filterRepeat, formatInItDate, initY, initYMD, initYMDHMS} from "@/sever/utils";
import hlsjs from "hls.js";
import {GetAge} from "@/sever/config";
import { getRiskList, getFvsHelmetToken, checkVideoHelmet } from "@/api/emp";
import {initColors} from "@/mixins/colorObj";

export const detailsModal = {
    mixins:[initColors],
    data() {
        return {
            fvsFlag:false,
            //地图信息
            fenceId:'',
            workArray:[],
            fenceActive: 0,
            fenceEmpFlag: false,
            fenceList:[],
            fenceIdList:[],
            fenceIdActive:"",
            zoomIndex:1,
            markers:[],
            typeList:[
                {
                    id:'0',
                    name:'人员定位',
                },
                {
                    id:'1',
                    name:'电子围栏',
                },
            ],
            fvsList:[],
            fvsId:'',
            fvsIdActive:'',
            fvsIconUrl:require("./../../assets/images/emp/index/fvs_sxt1.png"),
            mapObj:{},
            //视频
            videomodal:false,
            videoFlag: true,
            crew: {
                name: "",
                phone: "",
                gender: 1,
                birthday: "",
                idCardNo: "",
                idCardGrantOrg: "",
                headImg: require("./../../assets/images/emp/common/userImage.png"),
                src: require("./../../assets/images/common/noPeo.png"),
                idCardFront: "",
                idCardBack: "",
                idCardStartDate: "",
                idCardEndDate: "",
                nation: "",
                address: "",
                education: "",
                degree: "",
                corpId: "",
                jobTypeId: "",
                workRoleId: 2,
                workRoleName: "施工人员",
                workTypeId: "",
                workTypeName: "",
                leaderFlag: 0,
                avatar: "",
                personId: "",
                enterTime: new Date(),
                outerTime: "",
                postState: "",
                sn: "",
            },
            //年龄
            age: "",
            //二维码
            qrCodeSrc: "",
            detailsModal: false,
            tabActiveName:'1',
            //合同信息
            contractList:[],
            //详情
            detailsObj: {},
            //身份证类型
            CertificateTypeList: [
                {
                    id: 1,
                    name: "居民身份证",
                },
                {
                    id: 2,
                    name: "澳门永久居民证",
                },
                {
                    id: 3,
                    name: "澳门非永久居民证",
                },
                {
                    id: 4,
                    name: "澳门外地雇员身份识别证",
                },
                {
                    id: 5,
                    name: "澳门特别逗留证",
                },
            ],
            CertificateType: 1,
            //资格证书
            cretList: [],
            //银行卡
            bankList: [],
            bankTypelist:[],
            //工资记录
            payrollList:[],
            //奖惩记录
            rewardList:[],
            //培训记录
            trainList:[],
            pageNum_train:1,
            pageSize_train:10,
            current_train:1,
            totalCount_train:1,
            //交底记录
            confessList:[],
            totalCount_confess:0,
            pageSize_confess:10,
            current_confess:1,
            pageNum_confess:1,
            confessModal:false,
            confessIsAdd:false,
            userList:[],
            corpList:[],
            confess_submit_data:{
                projectName:'',
                empId:'',
                date:new Date(),
                corpId:'',
                corpName:'',
                confidantId:'',
                confidantName:'',
                beConfidantId:'',
                beConfidantName:'',
                imgUrlList:[],
            },

            //防疫信息
            healthList:[],
            totalCount_health:0,
            pageSize_health:10,
            current_health:1,
            pageNum_health:1,
            healthTitle:'添加健康码记录',
            healthActive:'healthCode',
            healthModal:false,
            healthIsAdd:false,
            options: {
                disabledDate(date) {
                    return date > Date.now();
                }
            },
            health_submit_data:{
                empId:'',
                type:'',
                date:new Date(),
                testResult:'1',
                expDate:new Date(),
                codeState:'green',
                journey:'',
                firstTime:new Date(),
                secondTime:new Date(),
                imgList:[],
            },
            imgFileList:[],
            //删除
            delModal:false,
            delId:'',
            delIndex:3,//删除下标
            getEmpHealthReportDel, //删除函数
            getEmpConfessDel, //删除函数
            delContent:'您是否确认删除此条数据？',//删除内容
            imgFlag:false,//图片最大上传


            //风险告知
            riskList:[],
            totalCount_risk:0,
            pageSize_risk:10,
            current_risk:1,
            pageNum_risk:1,
            uploadModal:false,

            /* 视频安全帽websocket */
            fvsHelmetSN: "",
            fvsHelmetToken: "",
            socket: null,
            tcPlayer: null
        }
    },
    methods:{
        //簽名
        submitSgin(){
            this.uploadModal = false;
            if(this.tabActiveName == 8){
                this.getEmpConfessListFn(this.detailsRows[this.detailsIndex].empId);
            }else if(this.tabActiveName == 10){
                this.getRiskListFn(this.detailsRows[this.detailsIndex].empId);
            }
        },
        uploadFn(id){
            if(window.location.hostname=='localhost' || window.location.hostname=='127.0.0.1'){
                let str;
                if(this.tabActiveName == 8){
                    str = `id=${id}-type=confess-emp=${this.detailsRows[this.detailsIndex].empId}`
                }else if(this.tabActiveName == 10){
                    str = `id=${id}-type=risk-emp=${this.detailsRows[this.detailsIndex].empId}`
                }
                window.open(`openIE:http://127.0.0.1:8000/pages/sign.html?${str}`);
            }else{
                let str ;
                if(this.tabActiveName == 8){
                    str = `id=${id}-type=confess-emp=${this.detailsRows[this.detailsIndex].empId}`
                }else if(this.tabActiveName == 10){
                    str = `id=${id}-type=risk-emp=${this.detailsRows[this.detailsIndex].empId}`
                }
                window.open(`openIE:http://zhgd.gbuvip.com/ms/pages/sign.html?${str}`);
            }
            setTimeout( ()=>{
                this.uploadModal = true;
            },3000)
        },
        //获取风险告知书
        getRiskListFn(id){
            let params = {
                empId: id,
                pageNum:this.pageNum_risk,
                pageSize:this.pageSize_risk,
            };
            getRiskList(params)
                .then(res => {
                    if (res.code == 200) {
                        this.riskList = res.data.list;
                        this.totalCount_risk = res.data.total;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        // 判断类型
        getIndexMapEmpTabFn(){
            let params = {
                deptId: this.deptId
            };
            getIndexMapEmpTab(params)
                .then(res => {
                    if (res.code == 200) {
                        this.fvsFlag = res.data;
                        if(this.fvsFlag){
                            this.fenceActive = localStorage.getItem('empActive') || '0';
                        }else{
                            this.fenceActive = (localStorage.getItem('empActive') == 2 ? '0' : localStorage.getItem('empActive')) || '0';
                        }
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        //获取电子围栏列表
        getFenceListFn() {
            this.fenceIdList = [];
            let params = {
                deptId: this.deptId
            };
            getFenceList(params)
                .then(res => {
                    if (res.code == 200) {
                        this.fenceIdList.push({
                            id:"",
                            name: "电子围栏:全部"
                        })
                        res.data.list.forEach(i=>{
                            this.fenceIdList.push(i)
                        })
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        // 切换电子围栏
        getFenceIdFn(item){
            this.fenceId = item;
            this.fenceIdActive = item;
            this.y = '';
            if(!this.fenceId){
                this.fenceEmpFlag = false;
            }else{
                this.fenceEmpFlag = true;
            }
            this.getIndexMapEmpPolyFn();
        },
        // 获取围栏信息
        getIndexMapEmpPolyFn(){
            let params = {
                deptId:this.deptId,
                groupId:this.groupId,
                empName: this.workCode,
                fenceId: this.fenceId,
            }
            getIndexMapEmpPoly(params).then(res=>{
                if(res.code == 200) {
                    let list = [];
                    this.fenceList =res.data.list;
                    res.data.list.forEach(v => {
                        v.idList = [];
                        v.empList.forEach(item => {
                            item.fenceId = v.id;
                            v.idList.push(item.empId)
                            list.push(item)
                        })
                    })
                    this.workArray = list;
                    this.workArray.forEach(i=>{
                        i.icon = i.iconUrl;
                    })
                    this.workArray = filterRepeat(this.workArray,'empId');
                    this.getAreaMap()
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        toProject(id){
            this.fenceId = id;
            this.fenceEmpFlag = true;
            this.getIndexMapEmpPolyFn();
        },
        getMapEmp(){
            let params = {
                deptId:this.deptId,
                groupId:this.groupId,
                empName: this.workCode,
            }
            getMapEmpList(params).then(res=>{
                if(res.code == 200) {
                    this.mapList = [];
                    let list  =res.data.list;
                    this.workArray = res.data.list;
                    this.workArray.forEach(i=>{
                        i.icon = i.iconUrl;
                    })
                    list.forEach(i => {
                        // i.icon = require("../../assets/images/emp/index/" + i.icon);
                        // i.icon = i.iconUrl;
                        let obj = {
                            lat: i.lat,
                            lng: i.lng,
                            icon: i.iconUrl,
                            id: i.empId,
                            machTypeName: i.machTypeName,
                            groupName:i.groupName,
                            empName: i.empName,
                            phone: i.phone,
                            state:i.state,
                            time:i.time,
                            localeState:i.localeState || 0,
                            attendState:i.attendState || 0,
                        };
                        this.mapList.push(obj);
                    });
                    let lat, lng;
                    let a = [];
                    let b = [];
                    this.mapList.forEach(i => {
                        a.push(i.lat);
                        b.push(i.lng);
                    });
                    //求和
                    let latSum = a.reduce((prev,cur)=>{
                        return prev + cur
                    },0)
                    let lngSum = b.reduce((prev,cur)=>{
                        return prev + cur
                    },0)
                    if(this.mapList.length>0){
                        lat = latSum / a.length;
                        lng = lngSum / b.length;
                    }else{
                        lat = this.$store.state.porjectObject.lat;
                        lng = this.$store.state.porjectObject.lng;
                    }
                    this.getEmpMap(lng, lat);
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //视频设备下的人员
        getFvsDetails(list){
            this.fenceList = list;
            this.workArray = list;
            let empList = [];
            list.forEach(v => {
                if(v.type == 2){
                    v.icon = v.iconUrl;
                    empList.push(v)
                }
            })
            this.workArray = empList;
            this.workArray = filterRepeat(this.workArray,'empId');
            this.getFvsMap()
        },
        setFvsDetails(item,type){
            if(type == 1){
                let list =  [];
                let fvsObj = {};
                for (let i = 0; i < this.fvsList.length; i++) {
                    if(item == this.fvsList[i].fvsDeviceId){
                        fvsObj = this.fvsList[i];
                        fvsObj.type = 1;
                        if(this.fvsList[i].empList && this.fvsList[i].empList.length > 0){
                            for (let j = 0; j < this.fvsList[i].empList.length; j++) {
                                let obj = this.fvsList[i].empList[j];
                                obj.type = 2;
                                list.push(obj)
                            }
                        }
                        this.fvsId = item;
                        this.fenceEmpFlag = true;
                        break
                    }
                }
                list = [fvsObj,...list];
                this.getFvsDetails(list);
            }else{

            }
        },
        //视频设备
        getFvsListFn(){
            this.fvsList = [];
            let params = {
                deptId:this.deptId,
                groupId:this.groupId,
                empName: this.workCode,
                fvsDeviceId: this.fvsId,
            }
            getIndexMapEmpFvs(params).then(res=>{
                if(res.code == 200) {
                    let arr = res.data.list;
                    arr = arr.filter(v => v.lat > 0 && v.lng > 0);
                    this.fvsList.push({
                        fvsDeviceId:"",
                        fvsDeviceName: "视频设备:全部"
                    })
                    let list = [];
                    arr.forEach(v => {
                        v.type = 1;
                        v.empList.forEach(item => {
                            item.type = 2;
                            list.push(item)
                        })
                    })
                    this.fvsList = [...this.fvsList,...arr];
                    this.fenceList = arr;
                    this.workArray = list;
                    this.workArray.forEach(i=>{
                        i.icon = i.iconUrl;
                    })
                    this.workArray = filterRepeat(this.workArray,'empId');
                    this.getFvsMap()
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //视频设备下拉框
        getFvsIdFn(item){
            this.fvsId = item;
            this.fvsIdActive = item;
            this.y = '';
            let list = [];
            this.fenceList = [];
            if(!this.fvsId){
                this.fenceEmpFlag = false;
                this.fvsList.forEach(v => {
                    if(v.fvsDeviceId){
                        this.fenceList.push(v)
                    }
                })
                this.getFvsMap();
            }else{
                let fvsObj = {};
                this.fenceEmpFlag = true;
                this.fvsList.forEach(v => {
                    if(v.fvsDeviceId == item){
                        fvsObj = v;
                        fvsObj.type = 1;
                        if(v.empList && v.empList.length > 0){
                            v.empList.forEach(val => {
                                let obj = val;
                                obj.type = 2;
                                list.push(obj)
                            })
                        }
                    }
                })
                list = [fvsObj,...list];
                this.getFvsDetails(list);
            }
        },
        //视频地图
        getFvsMap(id) {
            let _that = this;
            let list = this.fenceList;
            let zoom = 14;
            var zoomIndex = 1;
            let imageSize = 36;
            window.zoomIndex = zoomIndex;
            _that.mapObj = new AMap.Map("container", {
                resizeEnable: true, //是否监控地图容器尺寸变化
                expandZoomRange:true,
                zoom: 10, //初始化地图层级
                zooms:[3,16], //设置缩放级别范围 3-20 级
                center: [this.lng, this.lat], //初始化地图中心点
                mapStyle: this.isBoard || false ? 'amap://styles/grey' : '',
                // 高德地图卫星图配置（核心修改）
                baseMap: {
                    type: 'satellite'
                },
                layers: [new AMap.TileLayer.Satellite()], // 明确指定为卫星图（高德官方参数）
            });
            this.mapObj.clearMap();
            if(this.isProject){
                this.getProjectWorkArea(_that.mapObj);
            }
            function mapZoom(){
                zoom = _that.mapObj.getZoom(); //获取当前地图级别
                _that.zoomIndex = zoom / 10 ;
            }
            _that.mapObj.on('zoomchange', mapZoom);
            let markers = [];
            list.forEach((v , i ) => {
                let marker = new AMap.Marker({
                    map: _that.mapObj,
                    icon: new AMap.Icon({
                        image: v.type == 1 ? _that.fvsIconUrl : v.iconUrl,
                        size: new AMap.Size(36, 36), //图标大小
                        imageSize: new AMap.Size(imageSize, imageSize)
                    }),
                    id: v.type == 1 ? v.fvsDeviceId :  v.empId,
                    empNum: v.type == 1 ? v.empNum :  '',
                    infoWindowName: v.type == 1 ? v.fvsDeviceName : v.groupName + ' - ' +v.empName ,
                    groupName: v.type == 1 ? '' : v.groupName,
                    type: v.type,
                    empIndex:i,
                    streamMode:i.streamMode || '',
                    position: [v.lng, v.lat],
                    offset: new AMap.Pixel(-13, -30)
                });
                markers.push(marker);
                if(_that.fenceEmpFlag){
                    if(v.type == 1){
                        marker.setLabel({
                            offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                            content: `
                             <div class='labelBox padding-10 ${v.deviceStatus == 1 ?  "bgc-205fff" : "bgc-999999"}'>
                                <div class="name">${v.fvsDeviceName}</div>
                            </div>`, //设置文本标注内容
                            direction: "top" //设置文本标注方位
                        });
                    }else{
                        //出勤
                        if(v.localeState == 1 && v.attendState == 1){
                            marker.setLabel({
                                offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                                content: `
                            <div class='in_fo1 in_fo3'>${v.groupName +' - ' + v.empName}</div>`, //设置文本标注内容
                                direction: "top" //设置文本标注方位
                            });
                        }
                        //不在场
                        else if(v.localeState == 0  && v.attendState == 1){
                            marker.setLabel({
                                offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                                content: `
                            <div class='in_fo1 in_fo105'>${v.groupName +' - ' + v.empName}</div>`, //设置文本标注内容
                                direction: "top" //设置文本标注方位
                            });
                        }
                        //缺勤
                        else if(!v.attendState){
                            marker.setLabel({
                                offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                                content: `
                            <div class='in_fo1 in_fo105'>${v.groupName +' - ' + v.empName}</div>`, //设置文本标注内容
                                direction: "top" //设置文本标注方位
                            });
                        }
                    }
                    AMap.event.addListener(marker, "click", function(e) {
                        _that.fenceEmpFlag = true;
                        let type = e.target.Ce?e.target.Ce.type:e.target.De.type;
                        let empIndex = e.target.Ce?e.target.Ce.empIndex:e.target.De.empIndex;
                        let id = e.target.Ce?e.target.Ce.id:e.target.De.id;
                        let streamMode = e.target.Ce?e.target.Ce.streamMode:e.target.De.streamMode;

                        if(type == 2){
                            _that.getEmpDetails(empIndex,list)
                        }else{
                            _that.videomodal = true;
                            _that.getPlayVideo(id,streamMode)
                        }
                    });
                }else{
                    marker.setLabel({
                        offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                        content: `
                            <div class='labelBox ${v.deviceStatus == 1 ?  "bgc-205fff" : "bgc-999999"}'>
                                <div class="name">${v.fvsDeviceName}</div>
                                <div class="round">${v.empNum}</div>
                            </div>`, //设置文本标注内容
                        direction: "top" //设置文本标注方位
                    });
                    AMap.event.addListener(marker, "click", function(e) {
                        _that.fenceEmpFlag = true;
                        let id = e.target.Ce?e.target.Ce.id:e.target.De.id;
                        let type= e.target.Ce?e.target.Ce.type:e.target.De.type;
                        _that.setFvsDetails(id,type)
                    });
                }
                _that.mapObj.setFitView();
            })
            //聚合点
            var count = markers.length;
            let cluster;
            if (count >= 1) {
                var _renderClusterMarker = function(context) {
                    var factor = Math.pow(context.count / count, 1 / 18);
                    var div = document.createElement("div");
                    div.setAttribute("class", "abc")
                    var size = 75;
                    div.innerHTML = context.count;
                    context.marker.setOffset(
                        new AMap.Pixel(-size / 2, -size / 2)
                    );
                    context.marker.setContent(div);
                };
                addCluster(2);
            }
            function addCluster(tag) {
                if (cluster) {
                    cluster.setMap(null);
                }
                if (tag == 2) {
                    //完全自定义
                    cluster = new AMap.MarkerClusterer(_that.mapObj, markers, {
                        gridSize: 15,
                        renderClusterMarker: _renderClusterMarker
                    });
                } else if (tag == 1) {
                    //自定义图标
                    var sts = [
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/blue.png",
                            size: new AMap.Size(32, 32),
                            offset: new AMap.Pixel(-16, -16)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/green.png",
                            size: new AMap.Size(32, 32),
                            offset: new AMap.Pixel(-16, -16)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/orange.png",
                            size: new AMap.Size(36, 36),
                            offset: new AMap.Pixel(-18, -18)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/red.png",
                            size: new AMap.Size(48, 48),
                            offset: new AMap.Pixel(-24, -24)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/darkRed.png",
                            size: new AMap.Size(48, 48),
                            offset: new AMap.Pixel(-24, -24)
                        }
                    ];
                    cluster = new AMap.MarkerClusterer(_that.mapObj, markers, {
                        styles: sts,
                        gridSize: 80
                    });
                } else {
                    //默认样式
                    cluster = new AMap.MarkerClusterer(_that.mapObj, markers, {
                        gridSize: 20
                    });
                }
            }
            if(markers.length > 0) {
                // 获取地图的缩放级别，如果级别已经是最高，那么点击后，显示聚合点内的点信息
                cluster.on('click', function (e, markers) {
                    if (_that.mapObj.getZoom() == 18) {
                        let itemsContent = "";
                        e.markers.forEach(function (item, index) {
                            let type = item.Ce.type;
                            let infoWindowName = item.Ce.infoWindowName;
                            let id = item.Ce.id;
                            let empIndex = item.Ce.empIndex;
                            let streamMode = item.Ce.streamMode;
                            if (type == 2) {
                                itemsContent += `
                                <div class="item" onclick="getEmpDetailsBtn(${empIndex})">${infoWindowName}</div>
                            `;
                            } else {
                                itemsContent += `
                                <div class="item" onclick="getPlayVideoBtn(${id},${streamMode})">${infoWindowName}</div>
                            `;
                            }
                        });
                        //人员详情
                        window.getEmpDetailsBtn = function (empIndex) {
                            _that.getEmpDetails(empIndex, list);
                        }
                        //视频播放
                        window.getPlayVideoBtn = function (id, streamMode) {
                            _that.videomodal = true;
                            _that.getPlayVideo(id, streamMode);
                        }
                        e.markers.forEach(function (item, index) {
                            // 创建一个自定义内容的 infowindow 实例
                            let infoWindow = new AMap.InfoWindow({
                                offset: new AMap.Pixel(0, -35),
                                content: itemsContent
                            });
                            infoWindow.open(_that.mapObj, item.getPosition());
                        });
                    }
                })
            }
        },
        //人员地图
        getEmpMap(lng, lat, id) {
            var _that = this;
            let list;
            list = [];
            list = _that.workArray;
            if (_that.mapList.length > 0) {
                console.log('123')
                _that.mapObj = new AMap.Map("container", {
                    resizeEnable: true,
                    expandZoomRange:true,
                    zoom: 16, //设置初始化级别
                    // zooms:[3,16], //设置缩放级别范围 3-20 级
                    center: [lng, lat],
                    mapStyle: this.isBoard || false ? 'amap://styles/grey' : '',
                    // 高德地图卫星图配置（核心修改）
                    baseMap: {
                        type: 'satellite'
                    },
                    layers: [new AMap.TileLayer.Satellite()], // 明确指定为卫星图（高德官方参数）
                });
            } else {
                console.log('456')
                _that.mapObj = new AMap.Map("container", {
                    resizeEnable: true,
                    zoom: 16, //设置初始化级别
                    // zooms:[3,16], //设置缩放级别范围 3-20 级
                    center: [lng, lat],
                    mapStyle: this.isBoard ? 'amap://styles/grey' : '',
                    // 高德地图卫星图配置（核心修改）
                    baseMap: {
                        type: 'satellite'
                    },
                    layers: [new AMap.TileLayer.Satellite()], // 明确指定为卫星图（高德官方参数）
                });
            }

            // 创建自定义瓦片图层
            const customTileLayer = new AMap.TileLayer({
                // 瓦片 URL 模板（{z}：缩放级别，{x}：X坐标，{y}：Y坐标）
                tileUrl: `http://121.229.145.152:20007/img/[z]/[x]/[y].png`, // 基于 public 目录的相对路径
                zIndex: 100, // 图层层级（确保在最底层）
            });
            _that.mapObj.add(customTileLayer);

            if(this.isProject){
                this.getProjectWorkArea(_that.mapObj);
            }
            var cluster,
                markers = [];
            let imageSize;
            imageSize = 36;
            _that.mapList.forEach((i , index) => {
                var marker = new AMap.Marker({
                    map: _that.mapObj,
                    icon: new AMap.Icon({
                        image: i.icon,
                        size: new AMap.Size(36, 36), //图标大小
                        imageSize: new AMap.Size(imageSize, imageSize)
                    }),
                    id: i.id || i.empId,
                    empName: i.empName || '',
                    groupName: i.groupName || '',
                    empIndex:index,
                    position: [i.lng, i.lat],
                    offset: new AMap.Pixel(-13, -30)
                });
                markers.push(marker);
                if(i.localeState == 1 && i.attendState == 1){
                    marker.setLabel({
                        offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                        content: "<div class='in_fo1 in_fo105'>" + i.groupName+' - ' + i.empName + "</div>", //设置文本标注内容
                        direction: "top" //设置文本标注方位
                    });
                }
                //不在场
                else if(i.localeState == 0  && i.attendState == 1){
                    marker.setLabel({
                        offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                        content: "<div class='in_fo1 in_fo105'>" + i.groupName +' - ' + i.empName + "</div>", //设置文本标注内容
                        direction: "top" //设置文本标注方位
                    });
                }
                //缺勤
                else if(i.attendState == 0){
                    marker.setLabel({
                        offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                        content: "<div class='in_fo1 in_fo105'>" + i.groupName +' - ' + i.empName + "</div>", //设置文本标注内容
                        direction: "top" //设置文本标注方位
                    });
                    //出勤
                }
                AMap.event.addListener(marker, "click", function(e) {
                    let empIndex = e.target.Ce?e.target.Ce.empIndex:e.target.De.empIndex
                    _that.getEmpDetails(empIndex,list)
                });
            });

            // 2. 添加自定义点位（新增逻辑）
            // 假设自定义点位数据存储在 _that.customPoints 中，格式示例：
            // [
            //   { lng: 116.39748, lat: 39.90882, name: '自定义点位1' },
            //   { lng: 116.40748, lat: 39.91882, name: '自定义点位2' }
            // ]
            let customPoints = [
                { lng: 106.359608210409, lat: 27.2884452206384, name: 'Z2' },
                { lng: 106.356056760977, lat: 27.2854039233779, name: 'Z3' },
                { lng: 106.364981166661, lat: 27.2846350425256, name: 'Z4' },
                { lng: 106.344959602405, lat: 27.2799979146129, name: 'Z5' },
                { lng: 106.357697122551, lat: 27.2769241380356, name: 'Z6' },
                { lng: 106.339530494036, lat: 27.2580799384758, name: 'Z7' },
                { lng: 106.335518228306, lat: 27.2589848566453, name: 'Z8' },
                { lng: 106.333270282127, lat: 27.2563466703017, name: 'Z9' },
                { lng: 106.344132705898, lat: 27.2572236948065, name: 'H11' },
                { lng: 106.376222660104, lat: 27.2477040689483, name: 'H12' },
                { lng: 106.373155068771, lat: 27.2357252063569, name: 'H13' },
                { lng: 106.380623994604, lat: 27.2306323381094, name: 'H14' },
                { lng: 106.37603257709, lat: 27.2275897081198, name: 'H15' },
                { lng: 106.377611151749, lat: 27.2234692605209, name: 'H16' },
                { lng: 106.369466035346, lat: 27.2200181027751, name: 'H17' },
                { lng: 106.361503258807, lat: 27.1953155118876, name: 'H18' },
                { lng: 106.369459263682, lat: 27.192010804047, name: 'H19' },
                { lng: 106.373985, lat: 27.246773, name: '', icon: require("./../../assets/images/emp/index/bdz.png") }
            ];
            if (customPoints && customPoints.length > 0) {
                customPoints.forEach((point, index) => {
                    // 创建自定义点位标记
                    const customMarker = new AMap.Marker({
                        map: _that.mapObj,
                        icon: new AMap.Icon({
                            // 自定义图标，默认使用红色标记图标
                            image: point.icon ? point.icon : require("./../../assets/images/emp/index/fj.png"),
                            // image: 'https://111.120.11.161:10006/images/fj.png',
                            size: new AMap.Size(36, 36),
                            imageSize: new AMap.Size(36, 36)
                        }),
                        id: `custom_${index}`,
                        name: point.name || `自定义点位${index + 1}`,
                        position: [point.lng, point.lat],
                        offset: new AMap.Pixel(-18, -36), // 图标偏移，根据实际图标调整
                        type: 'custom' // 类型标识
                    });

                    // 添加自定义点位标签
                    if (point.name) {
                        customMarker.setLabel({
                            offset: new AMap.Pixel(0, 0),
                            content: `<div class='in_fo1'>${point.name}</div>`,
                            direction: "top"
                        });
                    }

                    // 自定义点位点击事件
                    AMap.event.addListener(customMarker, "click", function(e) {
                        // 可以自定义点击逻辑，例如显示点位详情
                        console.log('点击了自定义点位：', e.target.get('name'));
                        // 如需显示信息窗口可添加以下代码
                        // const infoWindow = new AMap.InfoWindow({
                        //     content: `<div>${e.target.get('name')}</div>`,
                        //     offset: new AMap.Pixel(0, -30)
                        // });
                        // infoWindow.open(_that.mapObj, e.target.getPosition());
                    });

                    markers.push(customMarker); // 添加到标记数组，参与聚合
                });
            }
            /* 2. 添加自定义点位（新增逻辑）*/

            _that.mapObj.setFitView();
            //聚合点
            var count = markers.length;
            if (count >= 1) {
                var _renderClusterMarker = function(context) {
                    var factor = Math.pow(context.count / count, 1 / 18);
                    var div = document.createElement("div");
                    div.setAttribute("class", "abc")
                    var size = 75;
                    div.innerHTML = context.count;
                    context.marker.setOffset(
                        new AMap.Pixel(-size / 2, -size / 2)
                    );
                    context.marker.setContent(div);
                };
                addCluster(2);
            }
            function addCluster(tag) {
                if (cluster) {
                    cluster.setMap(null);
                }
                if (tag == 2) {
                    //完全自定义
                    cluster = new AMap.MarkerClusterer(_that.mapObj, markers, {
                        gridSize: 15,
                        renderClusterMarker: _renderClusterMarker,
                        minClusterSize: 15, // 最小聚合数量设为无穷大，禁用聚合
                    });
                } else if (tag == 1) {
                    //自定义图标
                    var sts = [
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/blue.png",
                            size: new AMap.Size(32, 32),
                            offset: new AMap.Pixel(-16, -16)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/green.png",
                            size: new AMap.Size(32, 32),
                            offset: new AMap.Pixel(-16, -16)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/orange.png",
                            size: new AMap.Size(36, 36),
                            offset: new AMap.Pixel(-18, -18)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/red.png",
                            size: new AMap.Size(48, 48),
                            offset: new AMap.Pixel(-24, -24)
                        },
                        {
                            url:
                                "https://a.amap.com/jsapi_demos/static/images/darkRed.png",
                            size: new AMap.Size(48, 48),
                            offset: new AMap.Pixel(-24, -24)
                        }
                    ];
                    cluster = new AMap.MarkerClusterer(_that.mapObj, markers, {
                        styles: sts,
                        gridSize: 80
                    });
                } else {
                    //默认样式
                    cluster = new AMap.MarkerClusterer(_that.mapObj, markers, {
                        gridSize: 20
                    });
                }
            }
            if(markers.length > 0){
                // 获取地图的缩放级别，如果级别已经是最高，那么点击后，显示聚合点内的点信息
                cluster.on('click',function(e,markers){
                if(_that.mapObj.getZoom() == 18){
                    let itemsContent = "";
                    e.markers.forEach(function (item, index) {
                        let infoWindowName = item.Ce.groupName + ' - ' +item.Ce.empName;
                        let empIndex = item.Ce.empIndex;
                        itemsContent += `
                            <div class="item" onclick="getEmpDetailsBtn(${empIndex})">${infoWindowName}</div>
                        `;
                    });
                    //人员详情
                    window.getEmpDetailsBtn = function (empIndex){
                        _that.getEmpDetails(empIndex,list);
                    }
                    e.markers.forEach(function (item, index) {
                        // 创建一个自定义内容的 infowindow 实例
                        let infoWindow = new AMap.InfoWindow({
                            offset: new AMap.Pixel(0, -35),
                            content: itemsContent
                        });
                        infoWindow.open(_that.mapObj, item.getPosition());
                    });
                }
            })
            }
        },
        //围栏地图
        getAreaMap() {
            let _that = this;
            let list = this.fenceList;
            let lng,lat,polygon,circle;
            let zoom = 14;
            var zoomIndex = 1;
            let num = 0;
            window.zoomIndex = zoomIndex;
            _that.mapObj = new AMap.Map("container", {
                resizeEnable: true, //是否监控地图容器尺寸变化
                expandZoomRange:true,
                zoom: 10, //初始化地图层级
                // zooms:[3,16], //设置缩放级别范围 3-20 级
                center: [this.lng, this.lat], //初始化地图中心点
                mapStyle: this.isBoard || false ? 'amap://styles/grey' : '',
                // 高德地图卫星图配置（核心修改）
                baseMap: {
                    type: 'satellite'
                },
                layers: [new AMap.TileLayer.Satellite()], // 明确指定为卫星图（高德官方参数）
            });

            // 创建自定义瓦片图层
            const customTileLayer = new AMap.TileLayer({
                // 瓦片 URL 模板（{z}：缩放级别，{x}：X坐标，{y}：Y坐标）
                tileUrl: `http://121.229.145.152:20007/img/[z]/[x]/[y].png`, // 基于 public 目录的相对路径
                zIndex: 100, // 图层层级（确保在最底层）
                // 瓦片范围限制（可选，防止加载不存在的瓦片）
                // bounds: new AMap.Bounds(
                //     [73.48, 18.14], // 西南角坐标（根据你的瓦片范围调整）
                //     [135.05, 53.56] // 东北角坐标
                // ),
                // 最小/最大缩放级别（需与你的瓦片覆盖范围匹配）
                // zooms: [1, 10]
            });
            this.mapObj.add(customTileLayer);

            this.mapObj.clearMap();
            if(this.isProject){
                this.getProjectWorkArea(_that.mapObj);
            }
            function mapZoom(){
                zoom = _that.mapObj.getZoom(); //获取当前地图级别
                _that.zoomIndex = zoom / 10 ;
            }
            _that.mapObj.on('zoomchange', mapZoom);
            let cluster,markers = [];
            list.forEach((v , i ) => {
                // console.log('vvvvvvvv', v);
                if (v.type == 1) {
                    //计算多边形中心点的坐标;
                    let polygonPointList = v.polygonPointList;
                    let a = [];
                    let b = [];
                    let path = [];
                    for (let i in polygonPointList) {
                        a.push(polygonPointList[i].lat);
                        b.push(polygonPointList[i].lng);
                        //多边形的坐标点
                        let x = [polygonPointList[i].lng, polygonPointList[i].lat];
                        path.push(x);
                    }
                    // 排序
                    let aSort =  a.sort((v,i)=>{ return v-i});
                    let bSort =  b.sort((v,i)=>{ return v-i});
                    lat = v.centerPoint.lat;
                    lng = v.centerPoint.lng;
                    polygon = new AMap.Polygon({
                        path: path,
                        strokeColor: this.colorList[i],
                        strokeWeight: 6,
                        strokeOpacity: v.idList.includes(_that.fenceIdActive) ?  0.5 : 0.2,
                        fillOpacity:    v.idList.includes(_that.fenceIdActive) ?  0.8 : 0.4,
                        fillColor: this.colorList[i],
                        zIndex: 50
                    });
                } else if (v.type == 2) {
                    lat = v.centerPoint.lat;
                    lng = v.centerPoint.lng;
                    let radius = v.radius;
                    circle = new AMap.Circle({
                        center: [lng, lat],
                        radius: radius, //半径
                        borderWeight: 3,
                        strokeColor: this.colorList[i],
                        strokeWeight: 6,
                        strokeOpacity:  v.idList.includes(_that.fenceIdActive) ?  0.5 : 0.2,
                        fillOpacity:    v.idList.includes(_that.fenceIdActive) ?  0.8 : 0.4,
                        strokeStyle: "dashed",
                        strokeDasharray: [10, 10],
                        fillColor: this.colorList[i],
                        zIndex: 50
                    });
                }
                if(_that.fenceEmpFlag){
                    let imageSize = 36;
                    v.empList.forEach((item , index)=> {
                        let marker = new AMap.Marker({
                            map: _that.mapObj,
                            icon: new AMap.Icon({
                                image: item.iconUrl,
                                size: new AMap.Size(36, 36), //图标大小
                                imageSize: new AMap.Size(imageSize, imageSize)
                            }),
                            id: item.empId,
                            empIndex:index,
                            position: [item.lng, item.lat],
                            offset: new AMap.Pixel(-13, -30)
                        });
                        markers.push(marker);
                        if(item.localeState == 1 && item.attendState == 1){
                            marker.setLabel({
                                offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                                content: "<div class='in_fo1 in_fo105'>" + item.groupName+' - ' + item.empName + "</div>", //设置文本标注内容
                                direction: "top" //设置文本标注方位
                            });
                        }
                        //不在场
                        else if(item.localeState == 0  && item.attendState == 1){
                            marker.setLabel({
                                offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                                content: "<div class='in_fo1 in_fo105'>" + item.groupName +' - ' + item.empName + "</div>", //设置文本标注内容
                                direction: "top" //设置文本标注方位
                            });
                        }
                        //缺勤
                        else if(!item.attendState){
                            marker.setLabel({
                                offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
                                content: "<div class='in_fo1 in_fo105'>" + item.groupName +' - ' + item.empName + "</div>", //设置文本标注内容
                                direction: "top" //设置文本标注方位
                            });
                            //出勤
                        }
                        AMap.event.addListener(marker, "click", function(e) {
                            _that.fenceEmpFlag = true;
                            let empIndex = e.target.Ce?e.target.Ce.empIndex:e.target.De.empIndex
                            _that.getEmpDetails(empIndex,v.empList)
                        });
                    })
                }else{
                    let marker = new AMap.Marker({
                        map: _that.mapObj,
                        position: [lng,lat],
                        // icon: new AMap.Icon({
                        //     size: new AMap.Size(32, 32),  //图标大小
                        //     image: require('../../assets/images/emp/index/emp_index_fence.png')
                        // })
                        icon: new AMap.Icon({
                            size: new AMap.Size(0, 0), // 图标大小设为0，不显示
                            image: '' // 透明1x1像素图片
                        }),
                    });
                    markers.push(marker);
                    marker.setLabel({
                        // offset: new AMap.Pixel(0, 32), //设置文本标注偏移量
                        offset: new AMap.Pixel(10, 60), //设置文本标注偏移量
                        /* content: `
                        <div onclick="toProject(${v.id})" class="in_fo3 mapIcon ${ v.idList.includes(_that.fenceIdActive) ? 'mapBoxShadow_G' :'mapBoxShadow_R'}" style='background: ${ v.idList.includes(_that.fenceIdActive) ? '#28C81E;' :'#1891FF;'}color:#fff;border-radius: 50%;'>
                            <p style='font-size:16px;color: #FFFFFF;'>${v.empList.length > 999 ? '999+' : v.empList.length }</p>
                        </div>
                        `, //设置文本标注内容 */
                        content: `
                        <div onclick="toProject(${v.id})">
                            <p style='font-size: 10px; color: #999;'>${v.name}</p>
                        </div>
                        `, //设置文本标注内容
                        direction: "top" //设置文本标注方位
                    });
                    window.toProject = function(id) {
                        _that.toProject(id)
                    };
                    v.idList.forEach(v => {
                        if(v == _that.fenceIdActive){
                            num += 1;
                        }
                    })
                    for (let i in markers) {
                        if (v.idList.includes(_that.fenceIdActive)) {
                            if(num > 1){
                                let lnglat =  markers[i];
                                var clickHandler = function(e) {
                                    _that.mapObj.setZoomAndCenter(
                                        10,
                                        lnglat.getPosition()
                                    );
                                };
                                //
                                _that.mapObj.on("click", clickHandler);
                                _that.mapObj.on("complete", function(e) {
                                    // 模拟触发地图click事件
                                    _that.mapObj.emit("click", {
                                        lnglat: _that.mapObj.Ce?_that.mapObjCe.overlays[i]:_that.mapObj.De.overlays[i]
                                    });
                                });
                            }else{
                                let lnglat =  markers[i];
                                var clickHandler = function(e) {
                                    _that.mapObj.setZoomAndCenter(
                                        13,
                                        lnglat.getPosition()
                                    );
                                };
                                //
                                _that.mapObj.on("click", clickHandler);
                                _that.mapObj.on("complete", function(e) {
                                    // 模拟触发地图click事件
                                    _that.mapObj.emit("click", {
                                        lnglat: _that.mapObj.Ce?_that.mapObj.Ce.overlays[i]:_that.mapObj.De.overlays[i]
                                    });
                                });
                            }

                        }
                    }
                }
                if (v.type == 1) {
                    _that.mapObj.add(polygon);
                    // 缩放地图到合适的视野级别
                    // _that.mapObj.setFitView([polygon]);
                } else if (v.type == 2) {
                    circle.setMap(_that.mapObj);
                    // 缩放地图到合适的视野级别
                    // _that.mapObj.setFitView([circle]);
                }
                _that.mapObj.setFitView();
            })
        },
        //人员详情
        async getEmpDetails(index, rows) {
            this.tabActiveName ="1";
            this.healthActive ="healthCode";
            let params = {
                empId: rows[index].empId,
            };
            this.detailsIndex = index;
            this.detailsRows = rows;
            if(!this.isBoard){
                this.mapObj.setFitView();
            }

            await checkVideoHelmet({ sn: rows[index].sn }).then(res=>{
                if(res.data){
                    this.fvsHelmetSN = rows[index].sn
                }else{
                    this.fvsHelmetSN = ""
                }
                return
            })
            getPersonnelDetails(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.detailsObj = res.data;
                        this.qrCodes(this.detailsIndex, this.detailsRows);
                        this.age = res.data.birthday ? GetAge(res.data.birthday) : "";

                        this.detailsModal = true;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        getPlayVideo(id,streamMode) {
            let params = {
                id
            };
            getStreamUrl(params)
                .then(res => {
                    if (res.code == 200) {
                        this.videoFlag = false;
                        let url ;
                        if(res.data.playUrl){
                            url = res.data.playUrl;
                            this.$refs.videoElement.setAttribute('src', url)
                        }else{
                            if(streamMode == 1){
                                url = res.data.hls;
                            }else{
                                url = res.data.hlsHd;
                            }
                            this.showVideo(url);
                        }
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        //play for flv
        showVideo(url) {
            let video = this.$refs.videoElement; //定义挂载点
            if (hlsjs.isSupported()) {
                this.hlsjs = new hlsjs();
                this.hlsjs.loadSource(url);
                this.hlsjs.attachMedia(video);
                this.hlsjs.on(hlsjs.Events.MANIFEST_PARSED, () => {
                    this.video.play();
                });
                this.hlsjs.on(hlsjs.Events.ERROR, (event, data) => {
                    // 监听出错事件
                });
            } else if (this.$refs.videoElement.canPlayType('application/vnd.apple.mpegurl')) {
                this.$refs.videoElement.src = source;
                this.$refs.videoElement.addEventListener('loadedmetadata', function () {
                    var _this = this;
                    _this.$refs.videoElement.play();
                });
            } else {
                this.$message.error("不支持的格式");
                return;
            }
        },
        cancelVideo() {
            if (this.hlsjs) {
                this.$refs.videoElement.pause();
                this.hlsjs.destroy();
                this.hlsjs = null;
            }
        },
        flv_close() {
            this.videomodal = false;
            if (!this.videoFlag) {
                this.$refs.videoElement.setAttribute('src', '')
                this.cancelVideo();
            } else if (this.videoFlag) {
                if (this.recordPlay == "" || this.recordPlay == undefined) {
                    return
                } else {
                    this.recordPlay.stop();
                }

            }
        },
        downloadQRCode() {
            let image = new Image();
            // 解决跨域 Canvas 污染问题
            image.setAttribute("crossOrigin", "anonymous");
            let canvas = document.createElement("canvas");
            let name = this.qrEmpName;
            image.onload = function () {
                canvas.width = image.width;
                canvas.height = image.height;
                let context = canvas.getContext("2d");
                context.drawImage(image, 0, 0, 300, 300);
                let url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
                let a = document.createElement("a"); // 生成一个a元素
                let event = new MouseEvent("click"); // 创建一个单击事件
                a.download = name; // 设置图片名称
                a.href = url; // 将生成的URL设置为a.href属性
                a.dispatchEvent(event); // 触发a的单击事件
            };
            image.src = this.qrCodeSrc;
        },
        //表格样式
        headClass(){
            return 'color: #5E5F60;background:#E1EAFA;important;'
        },
        beforeImgUpload(file){
            /* const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$Message.error("上传图片大小不能超过 2MB!");
            }
            return isLt2M; */
        },
        reportlogImgSuccess(res,file){
            let obj = {
                url: res.data.path,
                name:file.name
            };
            this.imgFileList.push(obj) ;
        },
        exceedImg(files,fileList){
            if(this.imgFileList.length==3){
                this.$Message.warning('上传图片最多3张');
                return;
            }
        },
        handleReportRemove(res, fileList){
            for (let i = 0; i < this.imgFileList.length; i++) {
                if (res.url == this.imgFileList[i].url) {
                    this.imgFileList.splice(i, 1);
                }
            }
        },

        //防疫信息数据提交
        healthSubmit(){
            let params = {};
            params.empId = this.detailsRows[this.detailsIndex].empId;
            params.type = this.healthActive;
            params.imgList = [];
            this.imgFileList.forEach(v=>{
                params.imgList.push(v.url)
            })
            if(this.healthActive == 'healthCode'){
                params.codeState = this.health_submit_data.codeState;
                params.date = this.health_submit_data.date;
            }else if(this.healthActive == 'journeyCard'){
                params.codeState = this.health_submit_data.codeState;
                params.date = this.health_submit_data.date;
                params.journey = this.health_submit_data.journey;
            }else if(this.healthActive == 'testRecord'){
                params.date = this.health_submit_data.date;
                params.testResult = this.health_submit_data.testResult;
                params.expDate = this.health_submit_data.expDate;
            }else if(this.healthActive == 'vaccination'){
                params.firstTime = this.health_submit_data.firstTime;
                params.secondTime = this.health_submit_data.secondTime;
            }
            if(!this.healthIsAdd){
                params.healthReportId = this.health_submit_data.healthReportId;
            }

            params = JSON.stringify(params);
            this.save(params);
        },
        save(params){
            params = JSON.parse(params);
            if(params.date){
                params.date = initYMD(params.date);
            }
            if(params.expDate){
                params.expDate = initYMD(params.expDate);
            }
            if(params.firstTime){
                params.firstTime = initYMD(params.firstTime);
            }
            if(params.secondTime){
                params.secondTime = initYMD(params.secondTime);
            }
            if(this.healthIsAdd) {
                getEmpHealthReportAdd(params).then(res =>{
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.healthModal = false;
                        this.current_health = 1;
                        this.pageNum_health = 1;
                        this.getEmpHealthReportListFn(this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            } else {
                getEmpHealthReportEdit(params).then(res =>{
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.healthModal = false;
                        this.current_health = 1;
                        this.pageNum_health = 1;
                        this.getEmpHealthReportListFn(this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            }
        },
        //防疫信息切换
        setHealthTabClick(){
            this.getEmpHealthReportListFn(this.detailsRows[this.detailsIndex].empId);
        },
        //添加编辑防疫信息
        setHealth(type,item){
            this.$refs.uploadImg.clearFiles();
            if(type == 1){
                this.healthIsAdd = true;
                if(this.healthActive == 'healthCode'){
                    this.healthTitle = '添加社保证明';
                }else if(this.healthActive == 'journeyCard'){
                    this.healthTitle = '添加体检报告';
                }else if(this.healthActive == 'testRecord'){
                    this.healthTitle = '添加核酸记录';
                }else if(this.healthActive == 'vaccination'){
                    this.healthTitle = '添加接种记录';
                }
                this.imgFileList = [];
                this.health_submit_data = {
                    empId:'',
                    type:'',
                    date:new Date(),
                    testResult:'1',
                    expDate:'',
                    codeState:'green',
                    journey:'',
                    firstTime:new Date(),
                    secondTime:new Date(),
                    imgList:[],
                }
            }else{
                if(this.healthActive == 'healthCode'){
                    this.healthTitle = '编辑健康码记录';
                }else if(this.healthActive == 'journeyCard'){
                    this.healthTitle = '编辑行程码记录';
                }else if(this.healthActive == 'testRecord'){
                    this.healthTitle = '编辑核酸记录';
                }else if(this.healthActive == 'vaccination'){
                    this.healthTitle = '编辑接种记录';
                }
                this.healthIsAdd = false;
                this.health_submit_data = {};
                for (const key in item) {
                    this.health_submit_data[key] = String(item[key]);
                }
                this.imgFileList = [];
                if(item.imgList && item.imgList.length > 0){
                    item.imgList.forEach(v => {
                        this.imgFileList.push({
                            url: v,
                        });
                    });
                }
            }
            this.healthModal = true;
        },
        getEmpHealthReportListFn(empId){
            let params = {
                empId,
                type:this.healthActive,
                pageNum:this.pageNum_health,
                pageSize:this.pageSize_health,
            }
            getEmpHealthReportList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.healthList = res.data.list;
                        this.totalCount_health = res.data.total;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //删除
        removeRow(delId,delIndex){
            this.delModal = true;
            this.delIndex = delIndex;
            this.delId = String(delId);
        },
        handleDelSubmit(delModal){
            this.delModal = delModal;
            if(this.delIndex == 3){
                if(this.healthActive == 'healthCode' || this.healthActive == 'journeyCard' || this.healthActive == 'testRecord' || this.healthActive == 'vaccination'){
                    this.current_health = 1;
                    this.pageNum_health = 1;
                    this.getEmpHealthReportListFn(this.detailsRows[this.detailsIndex].empId);
                }
            }else if(this.delIndex == 4){
                this.current_confess = 1;
                this.pageNum_confess = 1;
                this.getEmpConfessListFn(this.detailsRows[this.detailsIndex].empId);
            }
        },
        handleDelClose(delModal){
            this.delModal = delModal;
        },
        //获取资格证书
        getCretList(id) {
            let params = {
                empId: id,
            };
            getEmpCertList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.cretList = res.data.list;
                        this.cretList.forEach(v => {
                            v['imgAll'] = [];
                            if(v.fileAttachList && v.fileAttachList.length > 0){
                                v.fileAttachList.forEach(item => {
                                    v.imgAll.push(item.url);
                                })
                            }
                        })
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //提交资格证书
        certSubmit() {
            if (this.certName == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "证书名称不能为空",
                });
                return;
            }
            if (this.certCode == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "证书编号不能为空",
                });
                return;
            }
            if (this.certStartDate == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请选择发证日期",
                });
                return;
            }
            if (this.certExpireDate == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请选择证件有效期",
                });
                return;
            }
            if (this.certGrantOrg == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "发证机关不能为空",
                });
                return;
            }
            let certExpireDate, certStartDate;
            certExpireDate = formatInItDate(this.certExpireDate);
            certStartDate = formatInItDate(this.certStartDate);
            if (this.certIsAdd) {
                let params = {
                    empId: this.detailsRows[this.detailsIndex].empId,
                    certName: this.certName,
                    level: this.level,
                    certCode: this.certCode,
                    certStartDate: certStartDate,
                    certExpireDate: certExpireDate,
                    certGrantOrg: this.certGrantOrg,
                    fileAttachList:this.imgFileList,
                };
                getEmpCertAdd(params)
                    .then((res) => {
                        if (res.code == 200) {
                            this.$Message.success("操作成功");
                            this.certUpdateModal = false;
                            this.getCretList(this.detailsRows[this.detailsIndex].empId);
                        } else {
                            this.$Message.warning(res.msg);
                        }
                    })
                    .catch((error) => {
                        console.log(error);
                    });
            } else {
                let params = {
                    certId: this.certId,
                    empId: this.detailsRows[this.detailsIndex].empId,
                    certName: this.certName,
                    level: this.level,
                    certCode: this.certCode,
                    certStartDate: certStartDate,
                    certExpireDate: certExpireDate,
                    certGrantOrg: this.certGrantOrg,
                    fileAttachList:this.imgFileList,
                };
                getEmpCertEdit(params)
                    .then((res) => {
                        if (res.code == 200) {
                            this.$Message.success("操作成功");
                            this.certUpdateModal = false;
                            this.getCretList(this.detailsRows[this.detailsIndex].empId);
                        } else {
                            this.$Message.warning(res.msg);
                        }
                    })
                    .catch((error) => {
                        console.log(error);
                    });
            }
        },
        //删除资格证书
        removeCertRow(index, rows) {
            this.certdeteleId = rows[index].certId;
            this.certdeleteModal = true;
        },
        certdetele() {
            getEmpCertDel(this.certdeteleId)
                .then((res) => {
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.getCretList(this.detailsRows[this.detailsIndex].empId);
                        this.certdeleteModal = false;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //获取用户银行卡号
        getBankList(id){
            let params ={
                empId:id
            }
            getEmpBankList(params).then(res=>{
                if(res.code == 200) {
                    this.bankList =res.data.list;
                    this.bankList.forEach(i=>{
                        this.bankTypelist.forEach(v=>{
                            if(i.bankCode == v.code) {
                                i["bankType"] = v.name;
                            }
                        })
                        if(i.enableFlag == 0) {
                            i.enableFlag =false;
                        } else {
                            i.enableFlag = true;
                        }
                    })
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //新增编辑用户银行卡
        updateBank(type,index,rows){
            if(type == 0) {
                this.isAdd = true;
                this.bankIsAdd = true
                this.bankName = "";
                this.bankCode ="";
                this.bankNumber = "";
            } else if(type == 1) {
                this.isAdd = false;
                this.bankId = rows[index].bankId;
                this.bankNumber = rows[index].bankNumber;
                this.bankCode = rows[index].bankCode;
                this.bankName = rows[index].bankName;
            }
            this.bankUpdateModal =true;
        },
        //删除用户银行卡
        removeBank(index,rows){
            this.bankId = rows[index].bankId;
            this.bankdeleteModal = true;
        },
        //启用禁用用户银行卡
        getFlag(index,rows) {
            let params = {
                bankId :rows[index].bankId,
                enableFlag:rows[index].enableFlag?1:0,
            }
            getEmpBankEnable(params).then(res=>{
                if(res.code == 200) {
                    this.$Message.success("操作成功");
                    this.getBankList( this.detailsRows[this.detailsIndex].empId);
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //获取所有银行
        getwbankTypeList() {
            let params = {
                code: "bank_code",
            };
            getTypeList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.bankTypelist = res.data.childList;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        bankSubmit(){
            var reg = new RegExp("^[0-9]*$");
            if(this.bankCode == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请选择银行类型"
                });
                return;
            }
            if(this.bankName == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请填写银行名称"
                });
                return;
            }
            if(this.bankNumber == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请填写银行卡号"
                });
                return;
            }
            if(this.bankNumber.length > 19 || !reg.test(this.bankNumber)){
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请填写正确的银行卡号"
                });
                return;
            }
            let params ={};
            if(this.isAdd) {
                params ={
                    empId : this.detailsRows[this.detailsIndex].empId,
                    bankNumber:this.bankNumber,
                    bankCode:this.bankCode,
                    bankName:this.bankName,
                }
                getEmpBankAdd(params).then(res=>{
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.bankUpdateModal = false;
                        this.getBankList( this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            } else {
                params ={
                    bankId : this.bankId,
                    bankNumber:this.bankNumber,
                    bankCode:this.bankCode,
                    bankName:this.bankName,
                }
                getEmpBankEdit(params).then(res=>{
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.bankUpdateModal = false;
                        this.getBankList( this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            }
        },
        bankdetele(){
            getEmpBankDel(this.bankId)
                .then((res) => {
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.getBankList(  this.detailsRows[this.detailsIndex].empId);
                        this.bankdeleteModal = false;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //工资记录
        getPayrollList(id){
            let params ={
                empId : id,
            }
            getEmpGetPayrollList(params).then(res=>{
                if(res.code == 200) {
                    this.payrollList = res.data.list;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //奖惩记录
        getRewardList(id){
            let params ={
                empId : id,
            }
            getEmpGetRewardList(params).then(res=>{
                if(res.code == 200) {
                    this.rewardList = res.data.list;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //合同信息
        getContractList(id){
            let params ={
                empId : id,
            }
            getEmpContractList(params).then(res=>{
                if(res.code == 200) {
                    this.contractList = res.data.list;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //合同保存
        contractSubmit(){
            if(this.contract.contractNo == ""){
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "合同编号不能为空",
                });
                return;
            }
            if(this.value.length == 0) {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请选择合作期限",
                });
                return;
            }
            if(this.contractIsAdd) {
                let params ={
                    empId: this.detailsRows[this.detailsIndex].empId,
                    state:this.contract.state,
                    contractNo:this.contract.contractNo,
                    contactType:this.contract.contactType,
                    startDate:this.contract.startDate,
                    endDate:this.contract.endDate,
                    payType:this.payType,
                    salary:this.contract.salary,
                    fileAttachList:this.contract.fileAttachList,
                }
                getEmpContractAdd(params).then(res=>{
                    if(res.code == 200) {
                        this.$Message.success("操作成功");
                        this.contractUpdateModal = false;
                        this.getContractList(this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            } else {
                let params ={
                    id: this.contractId ,
                    state:this.contract.state,
                    contractNo:this.contract.contractNo,
                    contactType:this.contract.contactType,
                    startDate:this.contract.startDate,
                    endDate:this.contract.endDate,
                    payType:this.payType,
                    salary:this.contract.salary,
                    fileAttachList:this.contract.fileAttachList,
                }
                getEmpContractEdit(params).then(res=>{
                    if(res.code == 200) {
                        this.$Message.success("操作成功");
                        this.contractUpdateModal = false;
                        this.getContractList(this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            }
        },
        //删除合同
        removeContractRow(index,rows){
            this.contractId = rows[index].id;
            this.contractdeleteModal = true;
        },
        //新增编辑
        updateContract(type,index,rows){
            if(type == 0) {
                this.contractIsAdd =true;
                this.contract.state = 0;
                this.value =[];
                this.payType = "";
                this.contract.startDate ="";
                this.contract.endDate ="";
                this.contract.contactType =0;
                this.contract.contractNo = "";
                this.contract.fileAttachList =[];
                this.contract.salary ="";
            } else if (type == 1) {
                this.contractIsAdd =false;
                this.contractId = rows[index].id;
                this.contract.state = rows[index].state;
                this.value =[
                    rows[index].startDate,
                    rows[index].endDate
                ];
                this.payType = rows[index].payType;
                this.contract.startDate =rows[index].startDate;
                this.contract.endDate =rows[index].endDate;
                this.contract.contactType =rows[index].contactType;
                this.contract.contractNo = rows[index].contractNo;
                this.contract.fileAttachList =rows[index].fileAttachList;
                this.contract.salary =rows[index].salary;

            }
            this.contractUpdateModal = true;
        },
        contractdetele(){
            getEmpContractDel(this.contractId)
                .then((res) => {
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.getContractList(this.detailsRows[this.detailsIndex].empId);
                        this.contractdeleteModal = false;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        // 培训记录
        getEmpTrainListFn(id){
            let params ={
                empId : id,
                pageNum:this.pageNum_train,
                pageSize:this.pageSize_train,
            }
            getEmpTrainList(params).then(res=>{
                if(res.code == 200) {
                    this.trainList = res.data.list;
                    this.totalCount_train = res.data.total;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //添加or编辑安全交底
        setConfess(type,item){
            if(type == 1){
                this.confessIsAdd = true;
                this.confess_submit_data = {
                    projectName:'',
                    empId:'',
                    date:new Date(),
                    corpId:'',
                    corpName:'',
                    confidantId:'',
                    confidantName:'',
                    beConfidantId:'',
                    beConfidantName:'',
                    imgUrlList:[],
                }
                this.imgFileList = [];
            }else{
                this.confessIsAdd = false;
                this.confess_submit_data = {};
                for (const key in item) {
                    this.confess_submit_data[key] = item[key];
                }
                this.imgFileList = [];
                if(item.imgUrlList && item.imgUrlList.length > 0){
                    item.imgUrlList.forEach(v => {
                        this.imgFileList.push({
                            url: v,
                        });
                    });
                }
            }
            this.confessModal = true;
        },
        //获取施工单位
        getCorpName(item){
            this.confess_submit_data.corpId=item;
            this.corpList.forEach(v=>{
                if(item==v.corpId){
                    this.confess_submit_data.corpName = v.corpName;
                }
            })
        },
        //获取交底人
        getConfidantName(item){
            this.confess_submit_data.confidantId=item;
            this.userList.forEach(v=>{
                if(item==v.empId){
                    this.confess_submit_data.confidantName = v.empName;
                }
            })
        },
        //获取被交底人
        getBeConfidantName(item){
            this.confess_submit_data.beConfidantId=item;
            this.userList.forEach(v=>{
                if(item==v.empId){
                    this.confess_submit_data.beConfidantName = v.empName;
                }
            })
        },
        // 安全交底
        getEmpConfessListFn(id){
            let params ={
                empId : id,
                pageNum:this.pageNum_confess,
                pageSize:this.pageSize_confess,
            }
            getEmpConfessList(params).then(res=>{
                if(res.code == 200) {
                    this.confessList = res.data.list;
                    this.totalCount_confess = res.data.total;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        confessSubmit(){
            if(!this.confess_submit_data.projectName){
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请填写工程名称",
                });
                return;
            }
            if(!this.confess_submit_data.date){
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请选择交底时间",
                });
                return;
            }
            let params = this.confess_submit_data;
            params.imgUrlList = [];
            this.imgFileList.forEach(v=>{
                params.imgUrlList.push(v.url)
            })
            params.empId = this.detailsRows[this.detailsIndex].empId
            this.confessSave(JSON.stringify(params));
        },
        confessSave(params){
            params = JSON.parse(params);
            if(params.date){
                params.date = initYMD(params.date);
            }
            if(this.confessIsAdd) {
                getEmpConfessAdd(params).then(res =>{
                    if (res.code == 200){
                        this.$Message.success("操作成功");
                        this.confessModal = false;
                        this.current_confess = 1;
                        this.pageNum_confess = 1;
                        this.getEmpConfessListFn(this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            } else {
                getEmpConfessEdit(params).then(res =>{
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.confessModal = false;
                        this.current_confess = 1;
                        this.pageNum_confess = 1;
                        this.getEmpConfessListFn(this.detailsRows[this.detailsIndex].empId);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                }).catch(error=>{
                    console.log(error)
                })
            }
        },
        pageChange_train(index) {
            this.pageNum_train = index;
            this.getEmpTrainListFn(this.detailsRows[this.detailsIndex].empId);
        },
        pageChange_confess(index) {
            this.pageNum_confess = index;
            this.getEmpConfessListFn(this.detailsRows[this.detailsIndex].empId);
        },
        pageChange_health(index) {
            this.pageNum_health = index;
            this.getEmpHealthReportListFn(this.detailsRows[this.detailsIndex].empId);
        },
        pageChange_risk(index) {
            this.pageNum_risk = index;
            this.getRiskListFn(this.detailsRows[this.detailsIndex].empId);
        },
        qrCodes(index, rows) {
            this.qrEmpName = rows[index].empName;
            this.qrcodeId = rows[index].empId;
            getEmpQr(rows[index].empId)
                .then((res) => {
                    if (res.code == 200) {
                        this.qrCodeSrc = res.data.path;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //获取安全交底用户列表
        getEmpConfessUserListFn(){
            let params ={
                deptId:this.projectId,
                keyword:'',
            }
            getEmpConfessUserList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.userList = res.data.list;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        getAllCompangListFn(){
            let params ={
                deptId:this.projectId,
            }
            getAllCompangList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.corpList = res.data.list;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },

        /* 人员详情弹窗显示关闭 */
        changeVisible(state){
            if(state){
                if(this.fvsHelmetSN){
                    getFvsHelmetToken().then(res=>{
                        this.fvsHelmetToken = res.data
                        this.initWebsocket()
                    })
                }
            }else{
                if(this.fvsHelmetSN){
                    this.stopPush()
                    this.socket.close()
                }
            }
        },

        /* 视频安全帽 */
        // 初始化websocket
        initWebsocket(){
            if (typeof WebSocket === "undefined") {
                alert("您的浏览器不支持socket");
            } else {
                // 实例化socket
                let wsUrl = "wss://caps.runde.pro/wss"
                this.socket = new WebSocket(wsUrl);
                // 监听socket连接
                this.socket.onopen = this.open;
                // 监听socket错误信息
                this.socket.onerror = this.error;
                // 监听socket消息
                this.socket.onmessage = this.getMessage;
                //监听socket断开
                this.socket.onclose = this.getSocketClose;
            }
        },
        // 接收信息
        getMessage(e) {
            console.log(JSON.parse(e.data));
            let msg = JSON.parse(e.data)
            if(msg.cmd==="ma_open_rtsp"&&msg.msg_code==="PushSucc"){
                let url = msg.play_url[2]
                this.initTcPlayer(url)
            }
        },
        // 链接
        open() {
            console.log('WebSocket连接已打开！')
            this.webSocketLogin()
        },
        // 链接出错
        error() {
            this.open()
        },
        // 关闭
        getSocketClose(e) {
            if(e.code===1006){
                this.reconnet()
            }
        },
        // 重连
        reconnet() {
            console.log("断开重连");
            this.socket = null
            this.initWebsocket();
        },

        /* 视频安全帽登录 */
        webSocketLogin(){
            let message = {
                act: "ma_login",
                user_name: "科技",
                access_token: this.fvsHelmetToken
            }
            message = JSON.stringify(message)
            this.socket.send(message)
        },
        /* 获取安全帽播放地址 */
        getPlayUrl(){
            let message = {
                act: "ma_open_rtsp",
                device_id: this.fvsHelmetSN
            }
            message = JSON.stringify(message)
            this.socket.send(message)
        },
        /* 停止推流 */
        stopPush(){
            console.log("停止推流");
            let message = {
                act: "ma_stop_rtsp",
                device_id: this.fvsHelmetSN
            }
            message = JSON.stringify(message)
            this.socket.send(message)
            if(this.tcPlayer){
                this.tcPlayer.destroy()
            }
        },

        /* TCPlayer播放器初始化 */
        initTcPlayer(url) {
            var that = this
            this.tcPlayer = new TcPlayer("live_video", {
                // webrtc: url, //请替换成实际可用的播放地址
                m3u8: url,
                autoplay: true, //iOS 下 safari 浏览器，以及大部分移动端浏览器是不开放视频自动播放这个能力的
                muted: false,
                webrtcConfig: { streamType: "auto" },
                wording: {
                    2032: "请求视频失败，请检查网络",
                    2003: "请求视频失败，请检查网络",
                },
                listener: function (msg) {
                    if (msg.type == "error") {
                        console.log("请求视频失败，请检查网络");
                    }
                },
            })
        },
    },
    watch:{
        imgFileList(val, oldVal) {
            if (val.length == 3) {
                this.imgFlag = true;
            } else {
                this.imgFlag = false;
            }
        },
        videomodal(val){
            if(!val){
                this.$refs.videoElement.setAttribute('src', '')
                if (this.hlsjs) {
                    this.$refs.videoElement.pause();
                    this.hlsjs.destroy();
                    this.hlsjs = null;
                }
            }
        },
        fenceActive(val, oldVal){
            localStorage.setItem('empActive',val);
            this.fenceList = [];
            if(val == 0){
                this.getMapEmp();
            }else if(val == 1){
                this.fenceId = '';
                this.fenceEmpFlag = false;
                this.getIndexMapEmpPolyFn();
            }else if(val == 2){
                this.fvsId = '';
                this.fenceEmpFlag = false;
                this.getFvsListFn();
            }
        },
        tabActiveName(val){
            if(val == 2){
                this.getContractList(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 3){
                this.getCretList(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 4){
                this.getBankList(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 5){
                this.getPayrollList(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 6){
                this.getRewardList(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 7){
                this.getEmpTrainListFn(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 8){
                this.getEmpConfessListFn(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 9){
                this.getEmpHealthReportListFn(this.detailsRows[this.detailsIndex].empId);
            }else if(val == 10){
                this.getRiskListFn(this.detailsRows[this.detailsIndex].empId);
            }
            if(this.fvsHelmetSN){
                if(val == 11){
                    this.getPlayUrl()
                }else{
                    this.stopPush()
                }
            }
        },
    },
    mounted() {
        this.getwbankTypeList();
    }

}
